package cn.home.fenni.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.fenni.domain.HomeMedicineTixing;
import cn.home.fenni.service.IHomeMedicineTixingService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * tixingController
 * 
 * @author gm
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/tixing/tixing")
public class HomeMedicineTixingController extends BaseController
{
    @Autowired
    private IHomeMedicineTixingService homeMedicineTixingService;

    /**
     * 查询tixing列表
     */
    @PreAuthorize("@ss.hasPermi('tixing:tixing:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomeMedicineTixing homeMedicineTixing)
    {
        startPage();
        List<HomeMedicineTixing> list = homeMedicineTixingService.selectHomeMedicineTixingList(homeMedicineTixing);
        return getDataTable(list);
    }

    /**
     * 导出tixing列表
     */
    @PreAuthorize("@ss.hasPermi('tixing:tixing:export')")
    @Log(title = "tixing", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeMedicineTixing homeMedicineTixing)
    {
        List<HomeMedicineTixing> list = homeMedicineTixingService.selectHomeMedicineTixingList(homeMedicineTixing);
        ExcelUtil<HomeMedicineTixing> util = new ExcelUtil<HomeMedicineTixing>(HomeMedicineTixing.class);
        util.exportExcel(response, list, "tixing数据");
    }

    /**
     * 获取tixing详细信息
     */
    @PreAuthorize("@ss.hasPermi('tixing:tixing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(homeMedicineTixingService.selectHomeMedicineTixingById(id));
    }

    /**
     * 新增tixing
     */
    @PreAuthorize("@ss.hasPermi('tixing:tixing:add')")
    @Log(title = "tixing", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomeMedicineTixing homeMedicineTixing)
    {
        return toAjax(homeMedicineTixingService.insertHomeMedicineTixing(homeMedicineTixing));
    }

    /**
     * 修改tixing
     */
    @PreAuthorize("@ss.hasPermi('tixing:tixing:edit')")
    @Log(title = "tixing", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomeMedicineTixing homeMedicineTixing)
    {
        return toAjax(homeMedicineTixingService.updateHomeMedicineTixing(homeMedicineTixing));
    }

    /**
     * 删除tixing
     */
    @PreAuthorize("@ss.hasPermi('tixing:tixing:remove')")
    @Log(title = "tixing", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(homeMedicineTixingService.deleteHomeMedicineTixingByIds(ids));
    }
}
